<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/* ecdsa-modified-1.2.2.js (c) Stephan Thomas, Kenji Urushima | github.com/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE
<span class='line'>  2</span>  */</span><span class="WHIT">
<span class='line'>  3</span> </span><span class="COMM">/*
<span class='line'>  4</span>  * ecdsa-modified.js - modified Bitcoin.ECDSA class
<span class='line'>  5</span>  * 
<span class='line'>  6</span>  * Copyright (c) 2013-2021 Stefan Thomas (github.com/justmoon)
<span class='line'>  7</span>  *                         Kenji Urushima (kenji.urushima@gmail.com)
<span class='line'>  8</span>  * LICENSE
<span class='line'>  9</span>  *   https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE
<span class='line'> 10</span>  */</span><span class="WHIT">
<span class='line'> 11</span> 
<span class='line'> 12</span> </span><span class="COMM">/**
<span class='line'> 13</span>  * @fileOverview
<span class='line'> 14</span>  * @name ecdsa-modified-1.0.js
<span class='line'> 15</span>  * @author Stefan Thomas (github.com/justmoon) and Kenji Urushima (kenji.urushima@gmail.com)
<span class='line'> 16</span>  * @version jsrsasign 10.5.16 ecdsa-modified 1.2.2 (2022-Apr-08)
<span class='line'> 17</span>  * @since jsrsasign 4.0
<span class='line'> 18</span>  * @license &lt;a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE">MIT License&lt;/a>
<span class='line'> 19</span>  */</span><span class="WHIT">
<span class='line'> 20</span> 
<span class='line'> 21</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR.crypto</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="COMM">/**
<span class='line'> 25</span>  * class for EC key generation,  ECDSA signing and verifcation
<span class='line'> 26</span>  * @name KJUR.crypto.ECDSA
<span class='line'> 27</span>  * @class class for EC key generation,  ECDSA signing and verifcation
<span class='line'> 28</span>  * @description
<span class='line'> 29</span>  * &lt;p>
<span class='line'> 30</span>  * CAUTION: Most of the case, you don't need to use this class except
<span class='line'> 31</span>  * for generating an EC key pair. Please use {@link KJUR.crypto.Signature} class instead.
<span class='line'> 32</span>  * &lt;/p>
<span class='line'> 33</span>  * &lt;p>
<span class='line'> 34</span>  * This class was originally developped by Stefan Thomas for Bitcoin JavaScript library.
<span class='line'> 35</span>  * (See {@link https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/ecdsa.js})
<span class='line'> 36</span>  * Currently this class supports following named curves and their aliases.
<span class='line'> 37</span>  * &lt;ul>
<span class='line'> 38</span>  * &lt;li>secp192k1&lt;/li>
<span class='line'> 39</span>  * &lt;li>secp256r1, NIST P-256, P-256, prime256v1 (*)&lt;/li>
<span class='line'> 40</span>  * &lt;li>secp256k1 (*)&lt;/li>
<span class='line'> 41</span>  * &lt;li>secp384r1, NIST P-384, P-384 (*)&lt;/li>
<span class='line'> 42</span>  * &lt;li>secp521r1, NIST P-521, P-521 (*)&lt;/li>
<span class='line'> 43</span>  * &lt;/ul>
<span class='line'> 44</span>  * &lt;/p>
<span class='line'> 45</span>  */</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="NAME">KJUR.crypto.ECDSA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">curveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"secp256r1"</span><span class="PUNC">;</span><span class="WHIT">	</span><span class="COMM">// curve name default</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ecparams</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prvKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pubKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">	</span><span class="NAME">_BigInteger</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">	</span><span class="NAME">_ECPointFp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ECPointFp</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_crypto_ECDSA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.ECDSA</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_crypto_ECParameterDB</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.ECParameterDB</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">	</span><span class="NAME">_getName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto_ECDSA.getName</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">	</span><span class="NAME">_ASN1HEX</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ASN1HEX</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">	</span><span class="NAME">_getVbyListEx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_ASN1HEX.getVbyListEx</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">	</span><span class="NAME">_isASN1HEX</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_ASN1HEX.isASN1HEX</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> 
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rng</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">SecureRandom</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> 
<span class='line'> 63</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">P_OVER_FOUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> 
<span class='line'> 65</span> </span><span class="WHIT">    </span><span class="NAME">this.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"EC"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">    </span><span class="NAME">this.isPrivate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">    </span><span class="NAME">this.isPublic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> 
<span class='line'> 69</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">implShamirsTrick</span><span class="PUNC">(</span><span class="NAME">P</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Q</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.max</span><span class="PUNC">(</span><span class="NAME">k.bitLength</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l.bitLength</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Z</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">P.add2D</span><span class="PUNC">(</span><span class="NAME">Q</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">R</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">P.curve.getInfinity</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> 
<span class='line'> 74</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">--</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">	    </span><span class="NAME">R</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">R.twice2D</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 76</span> 
<span class='line'> 77</span> </span><span class="WHIT">	    </span><span class="NAME">R.z</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_BigInteger.ONE</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> 
<span class='line'> 79</span> </span><span class="WHIT">	    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">k.testBit</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l.testBit</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">		    </span><span class="NAME">R</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">R.add2D</span><span class="PUNC">(</span><span class="NAME">Z</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">		    </span><span class="NAME">R</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">R.add2D</span><span class="PUNC">(</span><span class="NAME">P</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l.testBit</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">		    </span><span class="NAME">R</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">R.add2D</span><span class="PUNC">(</span><span class="NAME">Q</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">	
<span class='line'> 92</span> 	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">R</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> 
<span class='line'> 95</span> </span><span class="WHIT">    </span><span class="COMM">//===========================</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">    </span><span class="COMM">// PUBLIC METHODS</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">    </span><span class="COMM">//===========================</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">    </span><span class="NAME">this.getBigRandom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">limit</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_BigInteger</span><span class="PUNC">(</span><span class="NAME">limit.bitLength</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rng</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">	</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">limit.subtract</span><span class="PUNC">(</span><span class="NAME">_BigInteger.ONE</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">	</span><span class="PUNC">.</span><span class="NAME">add</span><span class="PUNC">(</span><span class="NAME">_BigInteger.ONE</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">	</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> 
<span class='line'>105</span> </span><span class="WHIT">    </span><span class="NAME">this.setNamedCurve</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">curveName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">	</span><span class="NAME">this.ecparams</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto_ECParameterDB.getByName</span><span class="PUNC">(</span><span class="NAME">curveName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">	</span><span class="NAME">this.prvKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">	</span><span class="NAME">this.pubKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">	</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">curveName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> 
<span class='line'>112</span> </span><span class="WHIT">    </span><span class="NAME">this.setPrivateKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">prvKeyHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">        </span><span class="NAME">this.isPrivate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">	</span><span class="NAME">this.prvKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">prvKeyHex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> 
<span class='line'>117</span> </span><span class="WHIT">    </span><span class="NAME">this.setPublicKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">pubKeyHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">        </span><span class="NAME">this.isPublic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">	</span><span class="NAME">this.pubKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pubKeyHex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>121</span> 
<span class='line'>122</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>123</span>      * get X and Y hexadecimal string value of public key
<span class='line'>124</span>      * @name getPublicKeyXYHex
<span class='line'>125</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>126</span>      * @function
<span class='line'>127</span>      * @return {Array} associative array of x and y value of public key
<span class='line'>128</span>      * @since ecdsa-modified 1.0.5 jsrsasign 5.0.14
<span class='line'>129</span>      * @example
<span class='line'>130</span>      * ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1', 'pub': pubHex});
<span class='line'>131</span>      * ec.getPublicKeyXYHex() &rarr; { x: '01bacf...', y: 'c3bc22...' }
<span class='line'>132</span>      */</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">    </span><span class="NAME">this.getPublicKeyXYHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.pubKeyHex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"04"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"this method supports uncompressed format(04) only"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> 
<span class='line'>138</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams.keycharlen</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"malformed public key hex length"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> 
<span class='line'>142</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">	</span><span class="NAME">result.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">	</span><span class="NAME">result.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> 
<span class='line'>148</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>149</span>      * get NIST curve short name such as "P-256" or "P-384"
<span class='line'>150</span>      * @name getShortNISTPCurveName
<span class='line'>151</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>152</span>      * @function
<span class='line'>153</span>      * @return {String} short NIST P curve name such as "P-256" or "P-384" if it's NIST P curve otherwise null;
<span class='line'>154</span>      * @since ecdsa-modified 1.0.5 jsrsasign 5.0.14
<span class='line'>155</span>      * @example
<span class='line'>156</span>      * ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1', 'pub': pubHex});
<span class='line'>157</span>      * ec.getShortPCurveName() &rarr; "P-256";
<span class='line'>158</span>      */</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">    </span><span class="NAME">this.getShortNISTPCurveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.curveName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"secp256r1"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"NIST P-256"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">	    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"P-256"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"prime256v1"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"P-256"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"secp384r1"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"NIST P-384"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"P-384"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"P-384"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"secp521r1"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"NIST P-521"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"P-521"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"P-521"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> 
<span class='line'>171</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>172</span>      * generate a EC key pair
<span class='line'>173</span>      * @name generateKeyPairHex
<span class='line'>174</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>175</span>      * @function
<span class='line'>176</span>      * @return {Array} associative array of hexadecimal string of private and public key
<span class='line'>177</span>      * @since ecdsa-modified 1.0.1
<span class='line'>178</span>      * @example
<span class='line'>179</span>      * var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
<span class='line'>180</span>      * var keypair = ec.generateKeyPairHex();
<span class='line'>181</span>      * var pubhex = keypair.ecpubhex; // hexadecimal string of EC public key
<span class='line'>182</span>      * var prvhex = keypair.ecprvhex; // hexadecimal string of EC private key (=d)
<span class='line'>183</span>      */</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">    </span><span class="NAME">this.generateKeyPairHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biN</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'n'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biPrv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.getBigRandom</span><span class="PUNC">(</span><span class="NAME">biN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams.keycharlen</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPrv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0000000000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">biPrv.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">	</span><span class="NAME">this.setPrivateKeyHex</span><span class="PUNC">(</span><span class="NAME">hPrv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPub</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.generatePublicKeyHex</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'ecprvhex'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">hPrv</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'ecpubhex'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">hPub</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</span> 
<span class='line'>194</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>195</span>      * generate public key for EC private key
<span class='line'>196</span>      * @name generatePublicKeyHex
<span class='line'>197</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>198</span>      * @function
<span class='line'>199</span>      * @return {String} associative array of hexadecimal string of private and public key
<span class='line'>200</span>      * @example
<span class='line'>201</span>      * var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1', 'prv': prvHex});
<span class='line'>202</span>      * var pubhex = ec.generatePublicKeyHex(); // hexadecimal string of EC public key
<span class='line'>203</span>      * var pub ec.getPublicKeyXYHex() &rarr; { x: '01bacf...', y: 'c3bc22...' }
<span class='line'>204</span>      */</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">	</span><span class="NAME">this.generatePublicKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biPrv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_BigInteger</span><span class="PUNC">(</span><span class="NAME">this.prvKeyHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">epPub</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'G'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">multiply</span><span class="PUNC">(</span><span class="NAME">biPrv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biX</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">epPub.getX</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toBigInteger</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biY</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">epPub.getY</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toBigInteger</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams.keycharlen</span><span class="PUNC">;</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hX</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0000000000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">biX.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hY</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0000000000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">biY.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">charlen</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPub</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"04"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hX</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hY</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">		</span><span class="NAME">this.setPublicKeyHex</span><span class="PUNC">(</span><span class="NAME">hPub</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hPub</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>217</span> 
<span class='line'>218</span> </span><span class="WHIT">    </span><span class="NAME">this.signWithMessageHash</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hashHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.signHex</span><span class="PUNC">(</span><span class="NAME">hashHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.prvKeyHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> 
<span class='line'>222</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>223</span>      * signing to message hash
<span class='line'>224</span>      * @name signHex
<span class='line'>225</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>226</span>      * @function
<span class='line'>227</span>      * @param {String} hashHex hexadecimal string of hash value of signing message
<span class='line'>228</span>      * @param {String} privHex hexadecimal string of EC private key
<span class='line'>229</span>      * @return {String} hexadecimal string of ECDSA signature
<span class='line'>230</span>      * @since ecdsa-modified 1.0.1
<span class='line'>231</span>      * @example
<span class='line'>232</span>      * var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
<span class='line'>233</span>      * var sigValue = ec.signHex(hash, prvKey);
<span class='line'>234</span>      */</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">    </span><span class="NAME">this.signHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hashHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">privHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_BigInteger</span><span class="PUNC">(</span><span class="NAME">privHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'n'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>238</span> 
<span class='line'>239</span> </span><span class="WHIT">	</span><span class="COMM">// message hash is truncated with curve key length (FIPS 186-4 6.4)</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_BigInteger</span><span class="PUNC">(</span><span class="NAME">hashHex.substring</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.ecparams.keycharlen</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>241</span> 
<span class='line'>242</span> </span><span class="WHIT">	</span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.getBigRandom</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">G</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'G'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Q</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">G.multiply</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Q.getX</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toBigInteger</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r.compareTo</span><span class="PUNC">(</span><span class="NAME">_BigInteger.ZERO</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</span> 
<span class='line'>249</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">k.modInverse</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">multiply</span><span class="PUNC">(</span><span class="NAME">e.add</span><span class="PUNC">(</span><span class="NAME">d.multiply</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>250</span> 
<span class='line'>251</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto_ECDSA.biRSSigToASN1Sig</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>253</span> 
<span class='line'>254</span> </span><span class="WHIT">    </span><span class="NAME">this.sign</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hash</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priv</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">priv</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'n'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_BigInteger.fromByteArrayUnsigned</span><span class="PUNC">(</span><span class="NAME">hash</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>258</span> 
<span class='line'>259</span> </span><span class="WHIT">	</span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.getBigRandom</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">G</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'G'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Q</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">G.multiply</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Q.getX</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toBigInteger</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r.compareTo</span><span class="PUNC">(</span><span class="NAME">BigInteger.ZERO</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>265</span> 
<span class='line'>266</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">k.modInverse</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">multiply</span><span class="PUNC">(</span><span class="NAME">e.add</span><span class="PUNC">(</span><span class="NAME">d.multiply</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.serializeSig</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>269</span> 
<span class='line'>270</span> </span><span class="WHIT">    </span><span class="NAME">this.verifyWithMessageHash</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hashHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sigHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.verifyHex</span><span class="PUNC">(</span><span class="NAME">hashHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sigHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.pubKeyHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>273</span> 
<span class='line'>274</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>275</span>      * verifying signature with message hash and public key
<span class='line'>276</span>      * @name verifyHex
<span class='line'>277</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>278</span>      * @function
<span class='line'>279</span>      * @param {String} hashHex hexadecimal string of hash value of signing message
<span class='line'>280</span>      * @param {String} sigHex hexadecimal string of signature value
<span class='line'>281</span>      * @param {String} pubkeyHex hexadecimal string of public key
<span class='line'>282</span>      * @return {Boolean} true if the signature is valid, otherwise false
<span class='line'>283</span>      * @since ecdsa-modified 1.0.1
<span class='line'>284</span>      * @example
<span class='line'>285</span>      * var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
<span class='line'>286</span>      * var result = ec.verifyHex(msgHashHex, sigHex, pubkeyHex);
<span class='line'>287</span>      */</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">    </span><span class="NAME">this.verifyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hashHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sigHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pubkeyHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>291</span> 
<span class='line'>292</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto_ECDSA.parseSigHex</span><span class="PUNC">(</span><span class="NAME">sigHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">	    </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj.r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">	    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj.s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">	    
<span class='line'>296</span> 	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Q</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_ECPointFp.decodeFromHex</span><span class="PUNC">(</span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'curve'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pubkeyHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> 
<span class='line'>298</span> </span><span class="WHIT">	    </span><span class="COMM">// message hash is truncated with curve key length (FIPS 186-4 6.4)</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_BigInteger</span><span class="PUNC">(</span><span class="NAME">hashHex.substring</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.ecparams.keycharlen</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>300</span> 
<span class='line'>301</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.verifyRaw</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Q</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>306</span> 
<span class='line'>307</span> </span><span class="WHIT">    </span><span class="NAME">this.verify</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hash</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pubkey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Bitcoin.Util.isArray</span><span class="PUNC">(</span><span class="NAME">sig</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parseSig</span><span class="PUNC">(</span><span class="NAME">sig</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">	    </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj.r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">	    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj.s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"object"</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sig.r</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sig.s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">	    </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sig.r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">	    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sig.s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Invalid value for signature"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>319</span> 
<span class='line'>320</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Q</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pubkey</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">ECPointFp</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">	    </span><span class="NAME">Q</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pubkey</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>323</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Bitcoin.Util.isArray</span><span class="PUNC">(</span><span class="NAME">pubkey</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>324</span> </span><span class="WHIT">	    </span><span class="NAME">Q</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_ECPointFp.decodeFrom</span><span class="PUNC">(</span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'curve'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pubkey</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Invalid format for pubkey value, must be byte array or ECPointFp"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>327</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_BigInteger.fromByteArrayUnsigned</span><span class="PUNC">(</span><span class="NAME">hash</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>329</span> 
<span class='line'>330</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.verifyRaw</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Q</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>331</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>332</span> 
<span class='line'>333</span> </span><span class="WHIT">    </span><span class="NAME">this.verifyRaw</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Q</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'n'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">G</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'G'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>336</span> 
<span class='line'>337</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r.compareTo</span><span class="PUNC">(</span><span class="NAME">_BigInteger.ONE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">	    </span><span class="NAME">r.compareTo</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>340</span> 
<span class='line'>341</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.compareTo</span><span class="PUNC">(</span><span class="NAME">_BigInteger.ONE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">	    </span><span class="NAME">s.compareTo</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>344</span> 
<span class='line'>345</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.modInverse</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>346</span> 
<span class='line'>347</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e.multiply</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r.multiply</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>349</span> 
<span class='line'>350</span> </span><span class="WHIT">	</span><span class="COMM">// TODO(!!!): For some reason Shamir's trick isn't working with</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT">	</span><span class="COMM">// signed message verification!? Probably an implementation</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">	</span><span class="COMM">// error!</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">	</span><span class="COMM">//var point = implShamirsTrick(G, u1, Q, u2);</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">G.multiply</span><span class="PUNC">(</span><span class="NAME">u1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">add</span><span class="PUNC">(</span><span class="NAME">Q.multiply</span><span class="PUNC">(</span><span class="NAME">u2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>355</span> 
<span class='line'>356</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">point.getX</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toBigInteger</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>357</span> 
<span class='line'>358</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">v.equals</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>360</span> 
<span class='line'>361</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>362</span>      * Serialize a signature into DER format.
<span class='line'>363</span>      *
<span class='line'>364</span>      * Takes two BigIntegers representing r and s and returns a byte array.
<span class='line'>365</span>      */</span><span class="WHIT">
<span class='line'>366</span> </span><span class="WHIT">    </span><span class="NAME">this.serializeSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>367</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rBa</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r.toByteArraySigned</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sBa</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.toByteArraySigned</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>369</span> 
<span class='line'>370</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sequence</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">	</span><span class="NAME">sequence.push</span><span class="PUNC">(</span><span class="NUMB">0x02</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// INTEGER</span><span class="WHIT">
<span class='line'>372</span> </span><span class="WHIT">	</span><span class="NAME">sequence.push</span><span class="PUNC">(</span><span class="NAME">rBa.length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">	</span><span class="NAME">sequence</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sequence.concat</span><span class="PUNC">(</span><span class="NAME">rBa</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>374</span> 
<span class='line'>375</span> </span><span class="WHIT">	</span><span class="NAME">sequence.push</span><span class="PUNC">(</span><span class="NUMB">0x02</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// INTEGER</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">	</span><span class="NAME">sequence.push</span><span class="PUNC">(</span><span class="NAME">sBa.length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">	</span><span class="NAME">sequence</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sequence.concat</span><span class="PUNC">(</span><span class="NAME">sBa</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>378</span> 
<span class='line'>379</span> </span><span class="WHIT">	</span><span class="NAME">sequence.unshift</span><span class="PUNC">(</span><span class="NAME">sequence.length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">	</span><span class="NAME">sequence.unshift</span><span class="PUNC">(</span><span class="NUMB">0x30</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// SEQUENCE</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sequence</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>383</span> 
<span class='line'>384</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>385</span>      * Parses a byte array containing a DER-encoded signature.
<span class='line'>386</span>      *
<span class='line'>387</span>      * This function will return an object of the form:
<span class='line'>388</span>      *
<span class='line'>389</span>      * {
<span class='line'>390</span>      *   r: BigInteger,
<span class='line'>391</span>      *   s: BigInteger
<span class='line'>392</span>      * }
<span class='line'>393</span>      */</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">    </span><span class="NAME">this.parseSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sig</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cursor</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sig</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0x30</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"Signature not a valid DERSequence"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>398</span> 
<span class='line'>399</span> </span><span class="WHIT">	</span><span class="NAME">cursor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sig</span><span class="PUNC">[</span><span class="NAME">cursor</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0x02</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"First element in signature must be a DERInteger"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rBa</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sig.slice</span><span class="PUNC">(</span><span class="NAME">cursor</span><span class="PUNC">+</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">cursor</span><span class="PUNC">+</span><span class="NUMB">2</span><span class="PUNC">+</span><span class="NAME">sig</span><span class="PUNC">[</span><span class="NAME">cursor</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>403</span> 
<span class='line'>404</span> </span><span class="WHIT">	</span><span class="NAME">cursor</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">+</span><span class="NAME">sig</span><span class="PUNC">[</span><span class="NAME">cursor</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sig</span><span class="PUNC">[</span><span class="NAME">cursor</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0x02</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"Second element in signature must be a DERInteger"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>407</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sBa</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sig.slice</span><span class="PUNC">(</span><span class="NAME">cursor</span><span class="PUNC">+</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">cursor</span><span class="PUNC">+</span><span class="NUMB">2</span><span class="PUNC">+</span><span class="NAME">sig</span><span class="PUNC">[</span><span class="NAME">cursor</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>408</span> 
<span class='line'>409</span> </span><span class="WHIT">	</span><span class="NAME">cursor</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">+</span><span class="NAME">sig</span><span class="PUNC">[</span><span class="NAME">cursor</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>410</span> 
<span class='line'>411</span> </span><span class="WHIT">	</span><span class="COMM">//if (cursor != sig.length)</span><span class="WHIT">
<span class='line'>412</span> </span><span class="WHIT">	</span><span class="COMM">//  throw new Error("Extra bytes in signature");</span><span class="WHIT">
<span class='line'>413</span> 
<span class='line'>414</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_BigInteger.fromByteArrayUnsigned</span><span class="PUNC">(</span><span class="NAME">rBa</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>415</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_BigInteger.fromByteArrayUnsigned</span><span class="PUNC">(</span><span class="NAME">sBa</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>416</span> 
<span class='line'>417</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">r</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>419</span> 
<span class='line'>420</span> </span><span class="WHIT">    </span><span class="NAME">this.parseSigCompact</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sig</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>421</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sig.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">65</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Signature has the wrong length"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>424</span> 
<span class='line'>425</span> </span><span class="WHIT">	</span><span class="COMM">// Signature is prefixed with a type byte storing three bits of</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">	</span><span class="COMM">// information.</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">27</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Invalid signature type"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>431</span> 
<span class='line'>432</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ecparams</span><span class="PUNC">[</span><span class="STRN">'n'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_BigInteger.fromByteArrayUnsigned</span><span class="PUNC">(</span><span class="NAME">sig.slice</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">33</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_BigInteger.fromByteArrayUnsigned</span><span class="PUNC">(</span><span class="NAME">sig.slice</span><span class="PUNC">(</span><span class="NUMB">33</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">65</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mod</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>435</span> 
<span class='line'>436</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">r</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>438</span> 
<span class='line'>439</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>440</span>      * read an ASN.1 hexadecimal string of PKCS#1/5 plain ECC private key&lt;br/>
<span class='line'>441</span>      * @name readPKCS5PrvKeyHex
<span class='line'>442</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>443</span>      * @function
<span class='line'>444</span>      * @param {String} h hexadecimal string of PKCS#1/5 ECC private key
<span class='line'>445</span>      * @since jsrsasign 7.1.0 ecdsa-modified 1.1.0
<span class='line'>446</span>      */</span><span class="WHIT">
<span class='line'>447</span> </span><span class="WHIT">    </span><span class="NAME">this.readPKCS5PrvKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_isASN1HEX</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>449</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"not ASN.1 hex string"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>450</span> 
<span class='line'>451</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hCurve</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hPrv</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hPub</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>453</span> </span><span class="WHIT">	    </span><span class="NAME">hCurve</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">"[0]"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"06"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">	    </span><span class="NAME">hPrv</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"04"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>455</span> </span><span class="WHIT">	    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT">		</span><span class="NAME">hPub</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">"[1]"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"03"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>457</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"malformed PKCS#1/5 plain ECC private key"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>461</span> 
<span class='line'>462</span> </span><span class="WHIT">	</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getName</span><span class="PUNC">(</span><span class="NAME">hCurve</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"unsupported curve name"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>464</span> 
<span class='line'>465</span> </span><span class="WHIT">	</span><span class="NAME">this.setNamedCurve</span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">	</span><span class="NAME">this.setPublicKeyHex</span><span class="PUNC">(</span><span class="NAME">hPub</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">	</span><span class="NAME">this.setPrivateKeyHex</span><span class="PUNC">(</span><span class="NAME">hPrv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT">        </span><span class="NAME">this.isPublic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>470</span> 
<span class='line'>471</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>472</span>      * read an ASN.1 hexadecimal string of PKCS#8 plain ECC private key&lt;br/>
<span class='line'>473</span>      * @name readPKCS8PrvKeyHex
<span class='line'>474</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>475</span>      * @function
<span class='line'>476</span>      * @param {String} h hexadecimal string of PKCS#8 ECC private key
<span class='line'>477</span>      * @since jsrsasign 7.1.0 ecdsa-modified 1.1.0
<span class='line'>478</span>      */</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">    </span><span class="NAME">this.readPKCS8PrvKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>480</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_isASN1HEX</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>481</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"not ASN.1 hex string"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>482</span> 
<span class='line'>483</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hECOID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hCurve</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hPrv</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hPub</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT">	    </span><span class="NAME">hECOID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"06"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT">	    </span><span class="NAME">hCurve</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"06"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">	    </span><span class="NAME">hPrv</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"04"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">	    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT">		</span><span class="NAME">hPub</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"[1]"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"03"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//.substr(2);</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"malformed PKCS#8 plain ECC private key"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>494</span> 
<span class='line'>495</span> </span><span class="WHIT">	</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getName</span><span class="PUNC">(</span><span class="NAME">hCurve</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"unsupported curve name"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>498</span> 
<span class='line'>499</span> </span><span class="WHIT">	</span><span class="NAME">this.setNamedCurve</span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>500</span> </span><span class="WHIT">	</span><span class="NAME">this.setPublicKeyHex</span><span class="PUNC">(</span><span class="NAME">hPub</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">	</span><span class="NAME">this.setPrivateKeyHex</span><span class="PUNC">(</span><span class="NAME">hPrv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">        </span><span class="NAME">this.isPublic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>504</span> 
<span class='line'>505</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>506</span>      * read an ASN.1 hexadecimal string of PKCS#8 ECC public key&lt;br/>
<span class='line'>507</span>      * @name readPKCS8PubKeyHex
<span class='line'>508</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>509</span>      * @function
<span class='line'>510</span>      * @param {String} h hexadecimal string of PKCS#8 ECC public key
<span class='line'>511</span>      * @since jsrsasign 7.1.0 ecdsa-modified 1.1.0
<span class='line'>512</span>      */</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT">    </span><span class="NAME">this.readPKCS8PubKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_isASN1HEX</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"not ASN.1 hex string"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>516</span> 
<span class='line'>517</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hECOID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hCurve</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hPub</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT">	    </span><span class="NAME">hECOID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"06"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT">	    </span><span class="NAME">hCurve</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"06"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT">	    </span><span class="NAME">hPub</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"03"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//.substr(2); </span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"malformed PKCS#8 ECC public key"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>525</span> 
<span class='line'>526</span> </span><span class="WHIT">	</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getName</span><span class="PUNC">(</span><span class="NAME">hCurve</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"unsupported curve name"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>529</span> 
<span class='line'>530</span> </span><span class="WHIT">	</span><span class="NAME">this.setNamedCurve</span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>531</span> </span><span class="WHIT">	</span><span class="NAME">this.setPublicKeyHex</span><span class="PUNC">(</span><span class="NAME">hPub</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>532</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>533</span> 
<span class='line'>534</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>535</span>      * read an ASN.1 hexadecimal string of X.509 ECC public key certificate&lt;br/>
<span class='line'>536</span>      * @name readCertPubKeyHex
<span class='line'>537</span>      * @memberOf KJUR.crypto.ECDSA#
<span class='line'>538</span>      * @function
<span class='line'>539</span>      * @param {String} h hexadecimal string of X.509 ECC public key certificate
<span class='line'>540</span>      * @param {Integer} nthPKI nth index of publicKeyInfo. (DEFAULT: 6 for X509v3)
<span class='line'>541</span>      * @since jsrsasign 7.1.0 ecdsa-modified 1.1.0
<span class='line'>542</span>      */</span><span class="WHIT">
<span class='line'>543</span> </span><span class="WHIT">    </span><span class="NAME">this.readCertPubKeyHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">nthPKI</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>544</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_isASN1HEX</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"not ASN.1 hex string"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>546</span> 
<span class='line'>547</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hCurve</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hPub</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>548</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT">	    </span><span class="NAME">hCurve</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"06"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT">	    </span><span class="NAME">hPub</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getVbyListEx</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"03"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>551</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>552</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"malformed X.509 certificate ECC public key"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>553</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>554</span> 
<span class='line'>555</span> </span><span class="WHIT">	</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getName</span><span class="PUNC">(</span><span class="NAME">hCurve</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>556</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>557</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Error</span><span class="PUNC">(</span><span class="STRN">"unsupported curve name"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>558</span> 
<span class='line'>559</span> </span><span class="WHIT">	</span><span class="NAME">this.setNamedCurve</span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>560</span> </span><span class="WHIT">	</span><span class="NAME">this.setPublicKeyHex</span><span class="PUNC">(</span><span class="NAME">hPub</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>561</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>562</span> 
<span class='line'>563</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>564</span>      * Recover a public key from a signature.
<span class='line'>565</span>      *
<span class='line'>566</span>      * See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
<span class='line'>567</span>      * Key Recovery Operation".
<span class='line'>568</span>      *
<span class='line'>569</span>      * http://www.secg.org/download/aid-780/sec1-v2.pdf
<span class='line'>570</span>      */</span><span class="WHIT">
<span class='line'>571</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>572</span>     recoverPubKey: function (r, s, hash, i) {
<span class='line'>573</span> 	// The recovery parameter i has two bits.
<span class='line'>574</span> 	i = i & 3;
<span class='line'>575</span> 
<span class='line'>576</span> 	// The less significant bit specifies whether the y coordinate
<span class='line'>577</span> 	// of the compressed point is even or not.
<span class='line'>578</span> 	var isYEven = i & 1;
<span class='line'>579</span> 
<span class='line'>580</span> 	// The more significant bit specifies whether we should use the
<span class='line'>581</span> 	// first or second candidate key.
<span class='line'>582</span> 	var isSecondKey = i >> 1;
<span class='line'>583</span> 
<span class='line'>584</span> 	var n = this.ecparams['n'];
<span class='line'>585</span> 	var G = this.ecparams['G'];
<span class='line'>586</span> 	var curve = this.ecparams['curve'];
<span class='line'>587</span> 	var p = curve.getQ();
<span class='line'>588</span> 	var a = curve.getA().toBigInteger();
<span class='line'>589</span> 	var b = curve.getB().toBigInteger();
<span class='line'>590</span> 
<span class='line'>591</span> 	// We precalculate (p + 1) / 4 where p is if the field order
<span class='line'>592</span> 	if (!P_OVER_FOUR) {
<span class='line'>593</span> 	    P_OVER_FOUR = p.add(BigInteger.ONE).divide(BigInteger.valueOf(4));
<span class='line'>594</span> 	}
<span class='line'>595</span> 
<span class='line'>596</span> 	// 1.1 Compute x
<span class='line'>597</span> 	var x = isSecondKey ? r.add(n) : r;
<span class='line'>598</span> 
<span class='line'>599</span> 	// 1.3 Convert x to point
<span class='line'>600</span> 	var alpha = x.multiply(x).multiply(x).add(a.multiply(x)).add(b).mod(p);
<span class='line'>601</span> 	var beta = alpha.modPow(P_OVER_FOUR, p);
<span class='line'>602</span> 
<span class='line'>603</span> 	var xorOdd = beta.isEven() ? (i % 2) : ((i+1) % 2);
<span class='line'>604</span> 	// If beta is even, but y isn't or vice versa, then convert it,
<span class='line'>605</span> 	// otherwise we're done and y == beta.
<span class='line'>606</span> 	var y = (beta.isEven() ? !isYEven : isYEven) ? beta : p.subtract(beta);
<span class='line'>607</span> 
<span class='line'>608</span> 	// 1.4 Check that nR is at infinity
<span class='line'>609</span> 	var R = new ECPointFp(curve,
<span class='line'>610</span> 			      curve.fromBigInteger(x),
<span class='line'>611</span> 			      curve.fromBigInteger(y));
<span class='line'>612</span> 	R.validate();
<span class='line'>613</span> 
<span class='line'>614</span> 	// 1.5 Compute e from M
<span class='line'>615</span> 	var e = BigInteger.fromByteArrayUnsigned(hash);
<span class='line'>616</span> 	var eNeg = BigInteger.ZERO.subtract(e).mod(n);
<span class='line'>617</span> 
<span class='line'>618</span> 	// 1.6 Compute Q = r^-1 (sR - eG)
<span class='line'>619</span> 	var rInv = r.modInverse(n);
<span class='line'>620</span> 	var Q = implShamirsTrick(R, s, G, eNeg).multiply(rInv);
<span class='line'>621</span> 
<span class='line'>622</span> 	Q.validate();
<span class='line'>623</span> 	if (!this.verifyRaw(e, r, s, Q)) {
<span class='line'>624</span> 	    throw "Pubkey recovery unsuccessful";
<span class='line'>625</span> 	}
<span class='line'>626</span> 
<span class='line'>627</span> 	var pubKey = new Bitcoin.ECKey();
<span class='line'>628</span> 	pubKey.pub = Q;
<span class='line'>629</span> 	return pubKey;
<span class='line'>630</span>     },
<span class='line'>631</span>     */</span><span class="WHIT">
<span class='line'>632</span> 
<span class='line'>633</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>634</span>      * Calculate pubkey extraction parameter.
<span class='line'>635</span>      *
<span class='line'>636</span>      * When extracting a pubkey from a signature, we have to
<span class='line'>637</span>      * distinguish four different cases. Rather than putting this
<span class='line'>638</span>      * burden on the verifier, Bitcoin includes a 2-bit value with the
<span class='line'>639</span>      * signature.
<span class='line'>640</span>      *
<span class='line'>641</span>      * This function simply tries all four cases and returns the value
<span class='line'>642</span>      * that resulted in a successful pubkey recovery.
<span class='line'>643</span>      */</span><span class="WHIT">
<span class='line'>644</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>645</span>     calcPubkeyRecoveryParam: function (address, r, s, hash) {
<span class='line'>646</span> 	for (var i = 0; i &lt; 4; i++) {
<span class='line'>647</span> 	    try {
<span class='line'>648</span> 		var pubkey = Bitcoin.ECDSA.recoverPubKey(r, s, hash, i);
<span class='line'>649</span> 		if (pubkey.getBitcoinAddress().toString() == address) {
<span class='line'>650</span> 		    return i;
<span class='line'>651</span> 		}
<span class='line'>652</span> 	    } catch (e) {}
<span class='line'>653</span> 	}
<span class='line'>654</span> 	throw "Unable to find valid recovery factor";
<span class='line'>655</span>     }
<span class='line'>656</span>     */</span><span class="WHIT">
<span class='line'>657</span> 
<span class='line'>658</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>659</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'curve'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>660</span> </span><span class="WHIT">	    </span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'curve'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>661</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>662</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>663</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">this.curveName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">curveName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>664</span> </span><span class="WHIT">    </span><span class="NAME">this.setNamedCurve</span><span class="PUNC">(</span><span class="NAME">this.curveName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>665</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>666</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params.prv</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">this.setPrivateKeyHex</span><span class="PUNC">(</span><span class="NAME">params.prv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>667</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params.pub</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">this.setPublicKeyHex</span><span class="PUNC">(</span><span class="NAME">params.pub</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>668</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>669</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>670</span> 
<span class='line'>671</span> </span><span class="COMM">/**
<span class='line'>672</span>  * parse ASN.1 DER encoded ECDSA signature
<span class='line'>673</span>  * @name parseSigHex
<span class='line'>674</span>  * @memberOf KJUR.crypto.ECDSA
<span class='line'>675</span>  * @function
<span class='line'>676</span>  * @static
<span class='line'>677</span>  * @param {String} sigHex hexadecimal string of ECDSA signature value
<span class='line'>678</span>  * @return {Array} associative array of signature field r and s of BigInteger
<span class='line'>679</span>  * @since ecdsa-modified 1.0.1
<span class='line'>680</span>  * @see {@link KJUR.crypto.ECDSA.parseSigHexInHexRS}
<span class='line'>681</span>  * @see {@link ASN1HEX.checkStrictDER}
<span class='line'>682</span>  * @throws Error when signature value is malformed.
<span class='line'>683</span>  * @example
<span class='line'>684</span>  * var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
<span class='line'>685</span>  * var sig = ec.parseSigHex('30...');
<span class='line'>686</span>  * var biR = sig.r; // BigInteger object for 'r' field of signature.
<span class='line'>687</span>  * var biS = sig.s; // BigInteger object for 's' field of signature.
<span class='line'>688</span>  */</span><span class="WHIT">
<span class='line'>689</span> </span><span class="NAME">KJUR.crypto.ECDSA.parseSigHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sigHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>690</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.ECDSA.parseSigHexInHexRS</span><span class="PUNC">(</span><span class="NAME">sigHex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>691</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">p.r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>692</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">p.s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>693</span> </span><span class="WHIT">    
<span class='line'>694</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'r'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">biR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'s'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">biS</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>695</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>696</span> 
<span class='line'>697</span> </span><span class="COMM">/**
<span class='line'>698</span>  * parse ASN.1 DER encoded ECDSA signature
<span class='line'>699</span>  * @name parseSigHexInHexRS
<span class='line'>700</span>  * @memberOf KJUR.crypto.ECDSA
<span class='line'>701</span>  * @function
<span class='line'>702</span>  * @static
<span class='line'>703</span>  * @param {String} sigHex hexadecimal string of ECDSA signature value
<span class='line'>704</span>  * @return {Array} associative array of signature field r and s in hexadecimal
<span class='line'>705</span>  * @since ecdsa-modified 1.0.3
<span class='line'>706</span>  * @see {@link KJUR.crypto.ECDSA.parseSigHex}
<span class='line'>707</span>  * @see {@link ASN1HEX.checkStrictDER}
<span class='line'>708</span>  * @throws Error when signature value is malformed.
<span class='line'>709</span>  * @example
<span class='line'>710</span>  * var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1'});
<span class='line'>711</span>  * var sig = ec.parseSigHexInHexRS('30...');
<span class='line'>712</span>  * var hR = sig.r; // hexadecimal string for 'r' field of signature.
<span class='line'>713</span>  * var hS = sig.s; // hexadecimal string for 's' field of signature.
<span class='line'>714</span>  */</span><span class="WHIT">
<span class='line'>715</span> </span><span class="NAME">KJUR.crypto.ECDSA.parseSigHexInHexRS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sigHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>716</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_ASN1HEX</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ASN1HEX</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>717</span> </span><span class="WHIT">	</span><span class="NAME">_getChildIdx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_ASN1HEX.getChildIdx</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>718</span> </span><span class="WHIT">	</span><span class="NAME">_getV</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_ASN1HEX.getV</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>719</span> 
<span class='line'>720</span> </span><span class="WHIT">    </span><span class="COMM">// 1. strict DER check</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT">    </span><span class="NAME">_ASN1HEX.checkStrictDER</span><span class="PUNC">(</span><span class="NAME">sigHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>722</span> 
<span class='line'>723</span> </span><span class="WHIT">    </span><span class="COMM">// 2. ASN.1 Sequence Check</span><span class="WHIT">
<span class='line'>724</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigHex.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"30"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>725</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"signature is not a ASN.1 sequence"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>726</span> 
<span class='line'>727</span> </span><span class="WHIT">    </span><span class="COMM">// 2. Items of ASN.1 Sequence Check</span><span class="WHIT">
<span class='line'>728</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getChildIdx</span><span class="PUNC">(</span><span class="NAME">sigHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>729</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>730</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"signature shall have two elements"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>731</span> 
<span class='line'>732</span> </span><span class="WHIT">    </span><span class="COMM">// 3. Integer tag check</span><span class="WHIT">
<span class='line'>733</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iTLV1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>734</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iTLV2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>735</span> 
<span class='line'>736</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigHex.substr</span><span class="PUNC">(</span><span class="NAME">iTLV1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"02"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>737</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"1st item not ASN.1 integer"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>738</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigHex.substr</span><span class="PUNC">(</span><span class="NAME">iTLV2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"02"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>739</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"2nd item not ASN.1 integer"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>740</span> 
<span class='line'>741</span> </span><span class="WHIT">    </span><span class="COMM">// 4. getting value and least zero check for DER</span><span class="WHIT">
<span class='line'>742</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getV</span><span class="PUNC">(</span><span class="NAME">sigHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iTLV1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>743</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getV</span><span class="PUNC">(</span><span class="NAME">sigHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iTLV2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>744</span> 
<span class='line'>745</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'r'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'s'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>746</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>747</span> 
<span class='line'>748</span> </span><span class="COMM">/**
<span class='line'>749</span>  * convert hexadecimal ASN.1 encoded signature to concatinated signature
<span class='line'>750</span>  * @name asn1SigToConcatSig
<span class='line'>751</span>  * @memberOf KJUR.crypto.ECDSA
<span class='line'>752</span>  * @function
<span class='line'>753</span>  * @static
<span class='line'>754</span>  * @param {String} asn1Hex hexadecimal string of ASN.1 encoded ECDSA signature value
<span class='line'>755</span>  * @return {String} r-s concatinated format of ECDSA signature value
<span class='line'>756</span>  * @throws Error when signature length is unsupported
<span class='line'>757</span>  * @since ecdsa-modified 1.0.3
<span class='line'>758</span>  */</span><span class="WHIT">
<span class='line'>759</span> </span><span class="NAME">KJUR.crypto.ECDSA.asn1SigToConcatSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">asn1Sig</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>760</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.ECDSA.parseSigHexInHexRS</span><span class="PUNC">(</span><span class="NAME">asn1Sig</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>761</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pSig.r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>762</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pSig.s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>763</span> 
<span class='line'>764</span> </span><span class="WHIT">	</span><span class="COMM">// P-521 special case (65-66 bytes are allowed)</span><span class="WHIT">
<span class='line'>765</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hR.length</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">130</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">hR.length</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">134</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hR.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"unknown ECDSA sig r length error"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>768</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hS.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"unknown ECDSA sig s length error"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hR.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hR.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>773</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hS.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hS.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>774</span> 
<span class='line'>775</span> </span><span class="WHIT">		</span><span class="COMM">// make sure they have the same length</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.max</span><span class="PUNC">(</span><span class="NAME">hR.length</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hS.length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">		</span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"000000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT">		</span><span class="NAME">hS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"000000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>779</span> 
<span class='line'>780</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>781</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>782</span> 
<span class='line'>783</span> </span><span class="WHIT">    </span><span class="COMM">// R and S length is assumed multiple of 128bit(32chars in hex).</span><span class="WHIT">
<span class='line'>784</span> </span><span class="WHIT">    </span><span class="COMM">// If leading is "00" and modulo of length is 2(chars) then</span><span class="WHIT">
<span class='line'>785</span> </span><span class="WHIT">    </span><span class="COMM">// leading "00" is for two's complement and will be removed.</span><span class="WHIT">
<span class='line'>786</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hR.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hR.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>787</span> </span><span class="WHIT">	</span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hR.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>788</span> 
<span class='line'>789</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hS.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hS.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>790</span> </span><span class="WHIT">	</span><span class="NAME">hS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hS.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>791</span> 
<span class='line'>792</span> </span><span class="WHIT">    </span><span class="COMM">// R and S length is assumed multiple of 128bit(32chars in hex).</span><span class="WHIT">
<span class='line'>793</span> </span><span class="WHIT">    </span><span class="COMM">// If missing two chars then it will be padded by "00".</span><span class="WHIT">
<span class='line'>794</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">hR.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">30</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>795</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">hS.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">30</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>796</span> 
<span class='line'>797</span> </span><span class="WHIT">    </span><span class="COMM">// If R and S length is not still multiple of 128bit(32 chars),</span><span class="WHIT">
<span class='line'>798</span> </span><span class="WHIT">    </span><span class="COMM">// then error</span><span class="WHIT">
<span class='line'>799</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hR.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>800</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"unknown ECDSA sig r length error"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>801</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hS.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>802</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"unknown ECDSA sig s length error"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>803</span> 
<span class='line'>804</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>805</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>806</span> 
<span class='line'>807</span> </span><span class="COMM">/**
<span class='line'>808</span>  * convert hexadecimal concatinated signature to ASN.1 encoded signature
<span class='line'>809</span>  * @name concatSigToASN1Sig
<span class='line'>810</span>  * @memberOf KJUR.crypto.ECDSA
<span class='line'>811</span>  * @function
<span class='line'>812</span>  * @static
<span class='line'>813</span>  * @param {String} concatSig r-s concatinated format of ECDSA signature value
<span class='line'>814</span>  * @return {String} hexadecimal string of ASN.1 encoded ECDSA signature value
<span class='line'>815</span>  * @throws Error when signature length is unsupported
<span class='line'>816</span>  * @since ecdsa-modified 1.0.3
<span class='line'>817</span>  */</span><span class="WHIT">
<span class='line'>818</span> </span><span class="NAME">KJUR.crypto.ECDSA.concatSigToASN1Sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">concatSig</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">concatSig.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT">		</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"unknown ECDSA concatinated r-s sig length error"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>822</span> 
<span class='line'>823</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">concatSig.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">concatSig.length</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>824</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">concatSig.substr</span><span class="PUNC">(</span><span class="NAME">concatSig.length</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>825</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.ECDSA.hexRSSigToASN1Sig</span><span class="PUNC">(</span><span class="NAME">hR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>826</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>827</span> 
<span class='line'>828</span> </span><span class="COMM">/**
<span class='line'>829</span>  * convert hexadecimal R and S value of signature to ASN.1 encoded signature
<span class='line'>830</span>  * @name hexRSSigToASN1Sig
<span class='line'>831</span>  * @memberOf KJUR.crypto.ECDSA
<span class='line'>832</span>  * @function
<span class='line'>833</span>  * @static
<span class='line'>834</span>  * @param {String} hR hexadecimal string of R field of ECDSA signature value
<span class='line'>835</span>  * @param {String} hS hexadecimal string of S field of ECDSA signature value
<span class='line'>836</span>  * @return {String} hexadecimal string of ASN.1 encoded ECDSA signature value
<span class='line'>837</span>  * @since ecdsa-modified 1.0.3
<span class='line'>838</span>  */</span><span class="WHIT">
<span class='line'>839</span> </span><span class="NAME">KJUR.crypto.ECDSA.hexRSSigToASN1Sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hS</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>840</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">hR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>841</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">hS</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>842</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.ECDSA.biRSSigToASN1Sig</span><span class="PUNC">(</span><span class="NAME">biR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">biS</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>843</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>844</span> 
<span class='line'>845</span> </span><span class="COMM">/**
<span class='line'>846</span>  * convert R and S BigInteger object of signature to ASN.1 encoded signature
<span class='line'>847</span>  * @name biRSSigToASN1Sig
<span class='line'>848</span>  * @memberOf KJUR.crypto.ECDSA
<span class='line'>849</span>  * @function
<span class='line'>850</span>  * @static
<span class='line'>851</span>  * @param {BigInteger} biR BigInteger object of R field of ECDSA signature value
<span class='line'>852</span>  * @param {BigInteger} biS BIgInteger object of S field of ECDSA signature value
<span class='line'>853</span>  * @return {String} hexadecimal string of ASN.1 encoded ECDSA signature value
<span class='line'>854</span>  * @since ecdsa-modified 1.0.3
<span class='line'>855</span>  */</span><span class="WHIT">
<span class='line'>856</span> </span><span class="NAME">KJUR.crypto.ECDSA.biRSSigToASN1Sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">biR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">biS</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>857</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.asn1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>858</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">derR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERInteger</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'bigint'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">biR</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>859</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">derS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERInteger</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'bigint'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">biS</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>860</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">derSeq</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERSequence</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'array'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">derR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">derS</span><span class="PUNC">]</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>861</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">derSeq.tohex</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>862</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>863</span> 
<span class='line'>864</span> </span><span class="COMM">/**
<span class='line'>865</span>  * static method to get normalized EC curve name from curve name or hexadecimal OID value
<span class='line'>866</span>  * @name getName
<span class='line'>867</span>  * @memberOf KJUR.crypto.ECDSA
<span class='line'>868</span>  * @function
<span class='line'>869</span>  * @static
<span class='line'>870</span>  * @param {String} s curve name (ex. P-256) or hexadecimal OID value (ex. 2a86...)
<span class='line'>871</span>  * @return {String} normalized EC curve name (ex. secp256r1) 
<span class='line'>872</span>  * @since jsrsasign 7.1.0 ecdsa-modified 1.1.0 
<span class='line'>873</span>  * @description
<span class='line'>874</span>  * This static method returns normalized EC curve name 
<span class='line'>875</span>  * which is supported in jsrsasign
<span class='line'>876</span>  * from curve name or hexadecimal OID value.
<span class='line'>877</span>  * When curve is not supported in jsrsasign, this method returns null.
<span class='line'>878</span>  * Normalized name will be "secp*" in jsrsasign.
<span class='line'>879</span>  * @example
<span class='line'>880</span>  * KJUR.crypto.ECDSA.getName("2b8104000a") &rarr; "secp256k1"
<span class='line'>881</span>  * KJUR.crypto.ECDSA.getName("NIST P-256") &rarr; "secp256r1"
<span class='line'>882</span>  * KJUR.crypto.ECDSA.getName("P-521") &rarr; undefined // not supported
<span class='line'>883</span>  */</span><span class="WHIT">
<span class='line'>884</span> </span><span class="NAME">KJUR.crypto.ECDSA.getName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>885</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"2b8104001f"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp192k1"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 1.3.132.0.31</span><span class="WHIT">
<span class='line'>886</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"2a8648ce3d030107"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp256r1"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 1.2.840.10045.3.1.7</span><span class="WHIT">
<span class='line'>887</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"2b8104000a"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp256k1"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 1.3.132.0.10</span><span class="WHIT">
<span class='line'>888</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"2b81040021"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp224r1"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 1.3.132.0.33</span><span class="WHIT">
<span class='line'>889</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"2b81040022"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp384r1"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 1.3.132.0.34</span><span class="WHIT">
<span class='line'>890</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"2b81040023"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp521r1"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 1.3.132.0.35</span><span class="WHIT">
<span class='line'>891</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"|secp256r1|NIST P-256|P-256|prime256v1|"</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp256r1"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>892</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"|secp256k1|"</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp256k1"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>893</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"|secp224r1|NIST P-224|P-224|"</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp224r1"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>894</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"|secp384r1|NIST P-384|P-384|"</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp384r1"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>895</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"|secp521r1|NIST P-521|P-521|"</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"secp521r1"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>896</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>897</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>898</span> 
<span class='line'>899</span> 
<span class='line'>900</span> 
<span class='line'>901</span> </span></pre></body></html>